#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int n,m,q;
int a[N],b[N];
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    cin>>q;
    int t1,t2,idx;
    while(q--)
    {
        cin>>t1>>t2;
        t1 -= a[t2];
        auto it=lower_bound(b+1,b+m+1,t1);
        if(it-b>m)
            cout<<"TNT" <<endl;
        else cout<<*it-t1<<endl;;
    }
     
    return 0;
}
